//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.dao.wills;

import com.aidong.dao.base.ConditionMap;
import com.aidong.dao.base.Pagination;
import com.aidong.dao.wills.BaseDao;
import com.aidong.model.wills.ReportPT;
import com.aidong.model.wills.ReportPTImpl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Repository;

@Repository
public class ReportPTDao extends BaseDao<ReportPT, Integer> {
	public ReportPTDao() {
	}

	public void getPTSalesRptList(Pagination<ReportPTImpl> pagination, ConditionMap cd) {
		ArrayList params = new ArrayList();
		String sqlw = cd.toSql(params);
		String sql = "select rm.ShopCode, ds.ChName as ShopName, rm.SalesCd, dc.ChName as SalesName, sum(rm.NewQty) as NewQty, sum(rm.NewAmount) as NewAmount, sum(rm.AdjournmentQty) as AdjournmentQty, sum(rm.AdjournmentAmount) as AdjournmentAmount,  sum(rm.PosQty) as PosQty, sum(rm.PosAmount) as PosAmount, sum(rm.AdjustmentQty) as AdjustmentQty, sum(rm.AdjustmentAmount) as AdjustmentAmount,  (sum(rm.NewAmount) + sum(rm.AdjournmentAmount) + sum(rm.PosAmount) + sum(rm.AdjustmentAmount)) as totalAmount  from ReportPT rm \n left outer  join DicShopCode ds on rm.ShopCode=ds.Code  \n left outer  join DicSalesCode dc on rm.SalesCd=dc.Code  \n" + (sqlw.length() > 0?"where " + sqlw:"") + " group by rm.ShopCode, ds.ChName, rm.SalesCd, dc.ChName \n";
		sql = sql + " order by totalAmount desc ";
		this.queryPageListBySql(ReportPTImpl.class, pagination, sql, params.toArray());
	}

	public List<ReportPTImpl> getExcelPTSalesRptList(ConditionMap cd) {
		ArrayList params = new ArrayList();
		String sqlw = cd.toSql(params);
		String sql = "select rm.ShopCode, ds.ChName as ShopName, rm.SalesCd, dc.ChName as SalesName, sum(rm.NewQty) as NewQty, sum(rm.NewAmount) as NewAmount, sum(rm.AdjournmentQty) as AdjournmentQty, sum(rm.AdjournmentAmount) as AdjournmentAmount,  sum(rm.PosQty) as PosQty, sum(rm.PosAmount) as PosAmount, sum(rm.AdjustmentQty) as AdjustmentQty, sum(rm.AdjustmentAmount) as AdjustmentAmount,  (sum(rm.NewAmount) + sum(rm.AdjournmentAmount) + sum(rm.PosAmount) + sum(rm.AdjustmentAmount)) as totalAmount  from ReportPT rm \n left outer  join DicShopCode ds on rm.ShopCode=ds.Code  \n left outer  join DicSalesCode dc on rm.SalesCd=dc.Code  \n" + (sqlw.length() > 0?"where " + sqlw:"") + " group by rm.ShopCode, ds.ChName, rm.SalesCd, dc.ChName \n";
		sql = sql + " order by totalAmount desc ";
		return this.queryListBySql(ReportPTImpl.class, sql, params.toArray());
	}
}
